$(function() {
	$('#doLogin').click(function() {
		var userName = $("#userName").val();
		var password = $("#password").val();
		if (userName == "" || userName == null) {
			showErrorMessageTip("请输入用户名", "userName");
			return;
		}
		if (password == "" || password == null) {
			showErrorMessageTip("请输入密码", "password");
			return;
		}
		var url_login = "/sys/login";
		var params_login = {
			"userName" : userName,
			"password" : password
		};
		getMapData(url_login, params_login, function(data, result) {
			if (result == "success") {
				location.href = '/';
			}
		}, true);
	});

	$(window).keydown(function(event) {
		if (event.which == 13) {
			$('#doLogin').click();
		}
	});

	var url_adminSysInfo = "/sys/getAdminSysInfo";
	var params_adminSysInfo = {};
	getMapData(url_adminSysInfo, params_adminSysInfo, function(data, result) {
		if (result == "success") {
			var info = data.info;
			var copyright = "";
			for (var i = 0; i < info.length; i++) {
				if (info[i].keys == 'copyright') {
					copyright += info[i].value;
				}
			}
			var company = "";
			for (var i = 0; i < info.length; i++) {
				if (info[i].keys == 'company') {
					company += info[i].value;
				}
//				if (info[i].keys == 'logo') {
//					if (info[i].value) {
//						$("#logo").attr("src", info[i].value);
//					}
//				}
			}
			$("#copyright").text(copyright);
			$("#company").text(company);
		}
	});

	var url_getLoginInfo = "/sys/getLoginInfo";
	var params_getLoginInfo = {};
	getMapData(url_getLoginInfo, params_getLoginInfo, function(data, result) {
		if (result == "success") {
			if (data != null && data != "") {
				location.href = '/';
			}
		}
	}, false);
});
